// Domain/Repositories/IUserRepository.cs
using System.Linq.Expressions;
using UniversalAdmin.Domain.Entities;

namespace UniversalAdmin.Domain.Repositories;

public interface IUserRepository : IRepository<User>
{
  // 用户特定查询
  Task<User?> GetByUsernameAsync(string username);
  Task<User?> GetByEmailAsync(string email);

  // 用户存在性检查
  Task<bool> IsUsernameExistsAsync(string username, int excludeUserId = 0);
  Task<bool> IsEmailExistsAsync(string email, int excludeUserId = 0);

  // 角色相关查询
  Task<IEnumerable<User>> GetUsersByRoleIdAsync(int roleId);
  Task<IEnumerable<User>> GetUsersByRoleNameAsync(string roleName);

  // 高级分页查询
  Task<(IEnumerable<User> Items, int TotalCount)> GetPagedUsersAsync(
      string? keyword = null,
      bool? isActive = null,
      IEnumerable<int>? roleIds = null,
      int pageIndex = 1,
      int pageSize = 10,
      Expression<Func<User, bool>>? additionalPredicate = null,
      Func<IQueryable<User>, IOrderedQueryable<User>>? orderBy = null);

  // 带导航属性的查询
  Task<User?> GetUserWithRolesAsync(int id);
  Task<User?> GetUserWithRolesAndLogsAsync(int id);
}